﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using GradeBook.Daos;
using GradeBook.Models;
using GradeBook.Security;

namespace GradeBook.Controllers
{
    public class TutorController : Controller
    {
        //
        // GET: /Tutor/

        [Authorize(Roles = "TUTOR")]
        public ActionResult Cabinet()
        {
            List<Group> groups = GroupDao.LoadByUserId(MemShPrvd.CurrUser().Id);
            return View(groups);
        }


        [Authorize(Roles = "TUTOR")]
        public ActionResult Group(int groupId)
        {
            List<User> users = UserDao.LoadSudentsByGroupId(groupId);
            return View(users);
        }

        [Authorize(Roles = "TUTOR")]
        public ActionResult TaskEditor(int studentId, int? taskId)
        {
            User student = UserDao.GetById(studentId);
            return View(
                new TaskModel
                    {
                        StudentId = studentId, 
                        StudentName = string.Format("{0} {1}", student.LastName, student.FirstName), 
                        TaskText = string.Empty, 
                        EndTime = DateTime.Now
                    });
        }
    }
}
